package wangjg.test.socks;

public class SocksUtil {
	
	public static String toHex(byte[] piByte, int len) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < len; i++) {
			int v = piByte[i] & 0xFF;
			if (v < 16)
				sb.append('0');
			sb.append(Integer.toString(v, 16).toUpperCase());
			sb.append(' ');
		}
		return sb.toString();
	}
	
	public static boolean compare(byte[] buf1, byte buf2[]){
		if(buf1==null||buf2==null){
			return true;
		}
		if((buf1!=null&&buf2==null)||(buf1==null&&buf2!=null)){
			return false;
		}
		if(buf1.length!=buf2.length){
			return false;
		}
		for(int i=0;i<buf1.length;i++){
			if(buf1[i]!=buf2[i]){
				return false;
			}
		}
		return true;
	}
}
